<?php
session_start();

require_once("database.include.php");

	$userName=$_SESSION['username'];
	$groupName = $_GET['groupName'];
	
	print "Group & User (table group_user)<br/><table border=`1`>";
	print "<tr><td bgcolor=darkgray><font color=white>group_user_id</font></td>
	<td bgcolor=darkgray><font color=white>group_name</font></td>
	<td bgcolor=darkgray><font color=white>user_name</font></td></tr>";
			
	$sql = ' SELECT `group_user_id`, `group_name`, `user_name` '
		    . ' FROM `group_user` '
			. ' WHERE `group_user`.group_name = ' . "'" . $groupName . "'" 
			. ' AND `group_user`.group_name in (select group_name FROM `group_user` where `group_user`.user_name = ' . "'" . $userName. "' )";
				
    foreach ($conn->query($sql) as $row) {
    	print "<tr>";
    	print "<td>" . $row['group_user_id'] . "</td>";
        print "<td>" . $row['group_name'] . "</td>";
        print "<td>" . $row['user_name'] . "</td>";
        print "</tr>";
    }
    print "</table>";

?>